<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>思途CMS3.0</title>
 {template 'stourtravel/public/public_js'}
   {php echo Common::getCss('style.css,base.css,base2.css,plist.css'); }
   {php echo Common::getCss('ext-theme-neptune-all-debug.css','js/extjs/resources/ext-theme-neptune/'); }
    
   {php echo Common::getScript("uploadify/jquery.uploadify.min.js,jquery.buttonbox.js,choose.js"); }
   {php echo Common::getCss('uploadify.css','js/uploadify/'); }
</head>
<body style="overflow:hidden">
<table class="content-tab">
   <tr>
    <td width="119px" class="content-lt-td"  valign="top">
     {template 'stourtravel/public/leftnav'}
    <!--右侧内容区-->
    </td>
    <td valign="top" class="content-rt-td" style="overflow:hidden">

 <div class="list-top-set">
   <div class="list-web-pad"></div>
   <div class="list-web-ct">
       <table class="list-head-tb">
           <tr>
               <td class="head-td-lt">
                   {loop $kindmenu $menu}
                   <a href="javascript:;" class="menu-shortcut" onclick="ST.Util.addTab('{$menu['name']}','{$menu['url']}',1);">{$menu['name']}</a>
                   {/loop}
               </td>
               <td class="head-td-rt">
                   <a href="javascript:;" class="refresh-btn" onclick="window.location.reload()">刷新</a>

           </tr>
       </table>
   </div>
 </div>

        <div class="search-bar filter" id="search_bar">
            <div class="pro-search ml-10" style=" float:left; margin-top:4px">
                <input type="text" id="searchkey" value="" datadef="会员账号" class="sty-txt1 set-text-xh wid_150">
                <a href="javascript:;" class="head-search-btn" onclick="CHOOSE.searchKeyword()"></a>
            </div>
        </div>
 <div id="product_grid_panel" class="content-nrt">
    
  </div>
  </td>
  </tr>
 </table> 
<script>


   // window.kindmenu = {$kindmenu};//分类设置菜单

  Ext.onReady(
    function() 
    {
		 Ext.tip.QuickTipManager.init();

        $(".btnbox").buttonBox();

        $("#searchkey").focusEffect();


		
		
		//产品store
        window.product_store=Ext.create('Ext.data.Store',{

		 fields:[
             'id',
             'account',
             'withdrawamount',
             'bankcardnumber',
             'bankaccountname',
             'bankname',
             'description',
             'status'
         ],
         proxy:{
		   type:'ajax',
		   api: {
              read: 'withdraw/action/read',  //读取数据的URL
			  update:'withdraw/action/save',
			  destroy:'withdraw/action/delete'
              },
		      reader:{
                type: 'json',   //获取数据的格式 
                root: 'lists',
                totalProperty: 'total'
                }	
	         },
		 remoteSort:true,	 
		 pageSize:30,	 	
         autoLoad:true,
		 listeners:{
             load:function( store, records, successful, eOpts )
             {
                 if(!successful){
                     ST.Util.showMsg("{__('norightmsg')}",5,1000);
                 }
                 var pageHtml=ST.Util.page(store.pageSize,store.currentPage,store.getTotalCount(),10);
                 $("#line_page").html(pageHtml);
                 window.product_grid.doLayout();
                 $(".pageContainer .pagePart a").click(function () {
                     var page = $(this).attr('page');
                     product_store.loadPage(page);
                 });

             }
		 }
		  
       });
	   
	  //产品列表 
	  window.product_grid=Ext.create('Ext.grid.Panel',{ 
	   store:product_store,
	   renderTo:'product_grid_panel',
	   border:0,
	   bodyBorder:0,
	   bodyStyle:'border-width:0px',
	   scroll:'vertical',
	   bbar: Ext.create('Ext.toolbar.Toolbar', {
                    store: product_store,  //这个和grid用的store一样
                    displayInfo: true,
                    emptyMsg: "没有数据了",
					items:[
                        {
                            xtype:'panel',
                            id:'listPagePanel',
                            html:'<div id="line_page"></div>'
                       },
					  {
						  xtype:'combo',
						  fieldLabel:'每页显示数量',
						  width:170,
						  labelAlign:'right',
						  forceSelection:true,
						  value:30,
						  store:{fields:['num'],data:[{num:30},{num:60},{num:100}]},
						  displayField:'num',
						  valueField:'num',
						  listeners:{
							  select:CHOOSE.changeNum
						  }
					  }
					
					],
				  listeners: {
						single: true,
						render: function(bar) {
							var items = this.items;
                            bar.insert(0,Ext.create('Ext.toolbar.Fill'));
						}
					}	
                 }), 		 			 
	   columns:[
               {
                   text:'账号',
                   width:'10%',
                   dataIndex:'account',
                   id:'column_series',
                   align:'center',
                   menuDisabled:true,
                   border:0,
                   sortable:false,
                   renderer : function(value, metadata,record) {
                       return value;
                   }
               },
			   {
				   text:'申请提现金额',
				   width:'20%',
				   dataIndex:'withdrawamount',
				   align:'center',
				   border:0,
				   sortable:false,
                   menuDisabled:true,
				   renderer : function(value, metadata,record) {
					         return value;
						}
				  
			   },
               {
                   text:'提现银行卡号',
                   width:'20%',
                   dataIndex:'bankcardnumber',
                   align:'center',
                   cls:'mod-1',
                   sortable:false,
                   menuDisabled:true,
                   renderer : function(value, metadata,record,rowIndex,colIndex) {
                      return value;
                   }
               },
			   {
				  text:'户名',
				  width:'10%',
				  dataIndex:'bankaccountname',
				  align:'center',
				  cls:'mod-1',
                   sortable:false,
                  menuDisabled:true
			   },
               {
                   text:'开户银行',
                   width:'10%',
                   dataIndex:'bankname',
                   align:'center',
                   cls:'mod-1',
                   sortable:false,
                   menuDisabled:true
               },
               {
                   text:'备注说明',
                   width:'10%',
                   dataIndex:'description',
                   align:'center',
                   cls:'mod-1',
                   sortable:false,
                   menuDisabled:true
               },
               {
                   text:'处理状态',
                   width:'10%',
                   dataIndex:'status',
                   align:'center',
                   cls:'mod-1 sort-col',
                   sortable:true,
                   menuDisabled:true,
                   renderer : function(value, metadata,record) {
                       var id = record.get('id');
                       if(value==0)
                         return '处理中';
                       if(value==1)
                         return '已完成';
                       if(value==2)
                         return '已取消';
                   }
               },
			   {
				   text:'管理',
				   width:'10%',
				   align:'center',
				   border:0,
				   sortable:false,
                   menuDisabled:true,
				   cls:'mod-2',
				   renderer : function(value, metadata,record) {
					     var id=record.get('id');
                         var account=record.get('account');
                         return '<a href="javascript:void(0);" title="查看编辑" class="row-mod-btn" onclick="goModify('+id+',\''+account+'\')"></a>';
                    }

			   }
			  
	           ],
			 listeners:{
		            boxready:function()
		            {
					
				
					    var height=Ext.dom.Element.getViewportHeight();
					   this.maxHeight=height-106;
					   this.doLayout();
		            },
					afterlayout:function(grid)
					{

						window.product_store.each(function(record){
				         id=record.get('id');


					   });
					   
					   var data_height=0;
					   try{
					     data_height=grid.getView().getEl().down('.x-grid-table').getHeight();
					   }catch(e)
					   {

					   }
					  var height=Ext.dom.Element.getViewportHeight();
					// console.log(data_height+'---'+height);
					  if(data_height>height-106)
					  {
						  window.has_biged=true;
						  grid.height=height-106;
					  }
					  else if(data_height<height-106)
					  {
						  if(window.has_biged)
						  {
							//delete window.product_grid.height;
							window.has_biged=false;  
							grid.doLayout();
						  }
					  }
				  }
			 },
			 plugins: [
                Ext.create('Ext.grid.plugin.CellEditing', {
                  clicksToEdit:2,
                  listeners:{
					 edit:function(editor, e)
					 {
						   var id=e.record.get('id');
						 //  var view_el=window.product_grid.getView().getEl();
						 // view_el.scrollBy(0,this.scroll_top,false);
						updateField(0,id,e.field,e.value,0);
						return false;
						  
					 },
					 beforeedit:function(editor,e)
					 {

						// var view_el=window.product_grid.getView().getEl();
	                     //this.scroll_top=view_el.getScrollTop();				   
	 
					 }
				 }
               })
             ],
			viewConfig:{
				//enableTextSelection:true
				}	   
	   });
	   
	  
	  
	})
	
	//实现动态窗口大小
  Ext.EventManager.onWindowResize(function(){ 
       var height=Ext.dom.Element.getViewportHeight(); 
	   var data_height=window.product_grid.getView().getEl().down('.x-grid-table').getHeight();
	   if(data_height>height-106)
	     window.product_grid.height=(height-106);
	   else
	      delete window.product_grid.height;
	   window.product_grid.doLayout();
	   
	 }) 
	

  

 
  //更新套餐的字段，并显示相应的text框，仅用于租车的支付方式
  function updateMixField(ele,id,field,value,type)
  {
	  if(type=='select')
	  {
		  var val=Ext.get(ele).getValue();
		 if(val==2)
		  Ext.get(ele).parent('table').down('input').show();
		 else
		  Ext.get(ele).parent('table').down('input').hide();  
	  }
	  updateField(ele,id,field,value,type);
  }
  
  //更新某个字段
  function updateField(ele,id,field,value,type,callback)
  {
	  var record=window.product_store.getById(id.toString());
	  if(type=='select'||type=='input')
	  {
		  value=Ext.get(ele).getValue();
	  }
	  var view_el=window.product_grid.getView().getEl();
	
	 
	  Ext.Ajax.request({
						 url   :  "list/action/update",
						 method  :  "POST",
						 datatype  :  "JSON",
						 params:{id:id,field:field,val:value,kindid:window.product_kindid},
						 success  :  function(response, opts) 
						 {
							 if(response.responseText=='ok')
							 {
							   record.set(field,value);
							   record.commit();
                               if(typeof(callback)=='function')
                                  callback(record);
							 }
                             else
                             {
                                 ST.Utils.showMsg("{__('norightmsg')}",5,1000);
                             }
						 }});

  }
  
  
  //删除套餐
  function delSuit(id)
  {
  }

    //修改
    function goModify(id,account)
    {
        var url = SITEURL+'fenxiao/withdraw_edit/parentkey/fenxiao/itemid/4/id/'+id;
        window.location.href=url;
      //  parent.window.addTab('提现'+account,url,0);
    }

 
</script>

</body>
</html>
